﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Icoders.MarketTracker.Reports.Lib.Domain;
using Icoders.MarketTracker.Reports.Lib.Repository;
using Icoders.MarketTracker.Reports.Lib.Repository.Transactions;
using Icoders.MarketTracker.Reports.Lib.Util;
using Microsoft.Reporting.WebForms;
using StructureMap;

namespace Icoders.MarketTracker.Web.rpt
{
    public partial class WebForm2 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                IReportRepository _reportRepository = ObjectFactory.GetInstance<IReportRepository>();
                ReportViewer1.Reset();
                ReportViewer1.LocalReport.DataSources.Clear();
                ReportViewer1.ProcessingMode = ProcessingMode.Local;
                ReportViewer1.LocalReport.EnableHyperlinks = true;

                var stream =
                    Assembly.GetAssembly(typeof(ReportBase)).GetManifestResourceStream(ReportCollective.SampleChart);
                ReportDataSource reportDataSource = new ReportDataSource("SampleChartDataset", _reportRepository.GetReport(null, null));
                ReportViewer1.LocalReport.DataSources.Add(reportDataSource);
                ReportViewer1.LocalReport.LoadReportDefinition(stream);

                ReportViewer1.LocalReport.DisplayName = "User";
                ReportViewer1.LocalReport.Refresh();
            }
        }
    }
}